package com.lcq.study.normal;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;

/**
 * @ClassName SortTest
 * @Description
 * @Author lichuanqi
 * @Date 2021/6/22 10:42
 * @Version 1.0
 **/
public class SortTest {
    public static void main(String[] args) {
        List<String> ids1 = Arrays.asList("1", "9", "20", "35", "26", "1s", "dd", "a8");
        //convertToInt(ids1);
        List<String> ids2 = Arrays.asList("9", "1", "8", "3", "26");
        Collections.sort(ids2, (id1, id2) -> Integer.parseInt(id2) - Integer.parseInt(id1));
        System.out.println(ids2);
    }


    private static void convertToInt(List<String> ids) {
        for (String id : ids) {
            boolean matches = Pattern.matches("^[0-9]*$", id);
            System.out.println(id + ":" + matches);
            if (matches) {
                int i = Integer.parseInt(id);
                System.out.println(i);
            }
        }
    }
}
